when
( service in module ngMockE2E
)
Creates a new backend definition.
method – {string} –
HTTP method.
url – {string|RegExp} –
HTTP url.
data(optional) – {(string|RegExp)=} –
HTTP request body.
headers(optional) – {(Object|function(Object))=} –
HTTP headers or function that receives http header object and returns true if the headers match the current definition.
{requestHandler}
– Returns an object with respond
and passThrough
methods that
control how a matched request is handled.
{function([status,] data[, headers])|function(function(method, url, data, headers)}
– The respond method takes a set of static data to be returned or a function that can return
an array containing response status (number), response data (string) and response headers
(Object).{function()}
– Any request matching a backend definition with passThrough
handler, will be pass through to the real backend (an XHR request will be made to the
server.